package com.example.demo.controller;


import com.example.demo.model.UserLoginRequest;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloWorldController {
    @GetMapping
    public String hello() {
        return "Hello World!";
    }

    @PostMapping
    public Boolean login(HttpServletRequest request, UserLoginRequest userLoginRequest) {
        String username = userLoginRequest.getUsername();
        String password = userLoginRequest.getPassword();
        if ("test".equals(username) && "123456".equals(password)) {
            request.getSession().setAttribute("USER_INFO", username);
            return true;
        }
        return false;

    }
}
